﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Configuration;
using System.Text.RegularExpressions;
using BlogHunter.Manager;

namespace BlogHunter
{
    class SinaBlog : Blog
    {
        public SinaBlog()
        {
            //Set Properties.
            AutoSplice = Convert.ToBoolean(ConfigurationSettings.AppSettings["SinaBlogHomePageAutoSplice"]);
            SpliceRule = ConfigurationSettings.AppSettings["SinaBlogHomePageSpliceRule"];
            OutPath = ConfigurationSettings.AppSettings["SinaOutPath"];

            EncodingCharset = ConfigurationSettings.AppSettings["SinaEncodingCharset"];

            //ReplacePatternBeforeExtract, used for removing peculiar HTML contents in Sina Blogs.
            ReplacePatternBeforeExtract = @"<span class=""atc_ic_b"">.*?</span>";

            BlogInfoRegex = new Regex(@"<a title=""([^""]*)"" target=""_blank"" href=""([^""]*)"">([^<]*)</a></span>([^<]*)<([^<]*)<([^<]*)<([^<]*)<([^<]*)<span class=""atc_tm SG_txtc"">([^<]*)<");
            LinkRegexGroupNum = Convert.ToInt32(ConfigurationSettings.AppSettings["SinaLinkRegexGroupNum"]);
            TitleRegexGroupNum = Convert.ToInt32(ConfigurationSettings.AppSettings["SinaTitleRegexGroupNum"]);
            DatetimeRegexGroupNum = Convert.ToInt32(ConfigurationSettings.AppSettings["SinaDatetimeRegexGroupNum"]);

            NextPageRegex = new Regex(@"href=""([^""]*)"" title=""([^""]*)"">下一页");
            NextPageRegexGroupNum = Convert.ToInt32(ConfigurationSettings.AppSettings["SinaNextPageRegexGroupNum"]);

            ChineseDateTimeRegex = new Regex(@"(\S{1,4})年(\S{1,2})月(\S{1,2})日");
            ChineseYearRegexGroupNum = Convert.ToInt32(ConfigurationSettings.AppSettings["SinaChineseYearRegexGroupNum"]);
            ChineseMonthRegexGroupNum = Convert.ToInt32(ConfigurationSettings.AppSettings["SinaChineseMonthRegexGroupNum"]);
            ChineseDateRegexGroupNum = Convert.ToInt32(ConfigurationSettings.AppSettings["SinaChineseDateRegexGroupNum"]);
        }
    }
}
